<?php
namespace Common\Controller;

use Think\Controller;
class IndexController extends Controller
{
    public function index()
    {
        $this->checklogin();
        $admin = $this->checkadmin();
        $this->assign('admin', $admin);
        $n = M('news');
        if ($admin['level'] == '1') {
            $w['show'] = array('neq', 2);
        } elseif ($admin['level'] == '2') {
            $w['show'] = array('neq', 1);
        } else {
            $w['show'] = array('neq', 3);
        }
        $news = $n->where($w)->order('time DESC')->select();
        $count = count($news);
        $Page = new \Think\Page($count, 20);
        $show = $Page->show();
        $news = array_slice($news, $Page->firstRow, $Page->listRows);
        $this->assign('page', $show);
        $this->assign('news', $news);
        $this->display();
    }
   
}